Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace unwrapping logic in strategies #13738

Merged
merged 61 commits into from
Aug 12, 2022
Merged

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Jul 19, 2022

What does this PR do?

Fixes #13502 (main RFC)
Fixes #8593
Fixes #13500

The PR looks big, but most complexity turns out to be in the deprecation. The rest of the changes are very thinly spread across multiple files, but are not complex by themselves.

Before, you would do

lightning_module = unwrap_lightning_module(self.model)

Now, directly access it:

lightning_module = self.lightning_module

Terminology:
self.model: refers to a LightningModule that is potentially wrapped
self.lightning_module: is always the pure LightningModule as it gets passed to Trainer.fit by the user. This attribute is read-access only.

TODOs:

  • backward compatibility in wrappers/deprecation

Does your PR introduce any breaking changes? If yes, please list them.

No.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

I made sure I had fun coding 🙃

cc @Borda @justusschock @awaelchli @rohitgr7 @tchaton @akihironitta

src/pytorch_lightning/CHANGELOG.md Show resolved Hide resolved
src/pytorch_lightning/strategies/sharded.py Show resolved Hide resolved
src/pytorch_lightning/overrides/base.py Outdated Show resolved Hide resolved
src/pytorch_lightning/overrides/base.py Outdated Show resolved Hide resolved
src/pytorch_lightning/overrides/base.py Outdated Show resolved Hide resolved
src/pytorch_lightning/overrides/data_parallel.py Outdated Show resolved Hide resolved
src/pytorch_lightning/overrides/fairscale.py Outdated Show resolved Hide resolved
Copy link
Contributor

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the description! It helped me review the change :) LGTM!

src/pytorch_lightning/overrides/fairscale.py Outdated Show resolved Hide resolved
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Aug 10, 2022
Copy link
Contributor

@rohitgr7 rohitgr7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could add comlpete version, it'd be nice.

else looks good.

@mergify mergify bot added has conflicts and removed ready PRs ready to be merged labels Aug 11, 2022
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Aug 11, 2022
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

@awaelchli awaelchli enabled auto-merge (squash) August 12, 2022 07:57
@awaelchli awaelchli merged commit 807f9d8 into master Aug 12, 2022
@awaelchli awaelchli deleted the refactor/remove-unwrap branch August 12, 2022 08:24
jessecambon pushed a commit to jessecambon/lightning that referenced this pull request Aug 16, 2022
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
akihironitta pushed a commit to lorcll/pytorch-lightning that referenced this pull request Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Includes a deprecation pl Generic label for PyTorch Lightning package ready PRs ready to be merged refactor strategy
Projects
No open projects
Status: Done
5 participants